home *** CD-ROM | disk | FTP | other *** search
/ Amiga Mag HDD Backup / Amiga Mag HDD Backup.zip / Amiga Mag HDD Backup / Alexander.img.bin / Alexander.img / 9.12 / Frawley⁄ Digital FX13 / DISFX.Seamless.ascii < prev    next >
Text File  |  1983-05-04  |  10KB  |  133 lines

  1. digital image special fx
  2. PART XIII:  Creating Quick and Easy Seamless Texture Maps
  3.  
  4. by William Frawley
  5.  
  6.  
  7.     Last time we discussed various methods for creating your own background images and 
  8. textures. This month, let's take that subject a bit further by examining a quick and relatively easy 
  9. technique for converting those appropriate images into seamless textures suitable for tiling onto 
  10. 3D objects. For those of you unfamiliar with 3D animation, perhaps a brief exposition is in order.
  11.  
  12. Seamless Defined
  13.     A seamless image is one whose sides are perfectly congruent with each other. In other words, 
  14. if the left edge of the image is abutted to the right edge of this same image, there will be no 
  15. visible "seam" between them.  The image's content will flow undetected into itself. This same 
  16. concept applies to both the top and bottom edges as well. A completely seamless image then 
  17. allows itself to be tiled, or laid side-to-side and/or top-to-bottom, thus forming one cohesive 
  18. pattern.
  19.  
  20. Usage
  21.     So why are seamless images so important? Well, maybe convenient is more accurate, but 
  22. their significance is nowhere more important than in the world of 3D texture mapping. With a 
  23. properly constructed seamless texture, one small image of a chain-link, for example, when 
  24. mapped repeatedly onto a plane will produce a whole chain-link fence. Get the picture (Figure 
  25. 1)? With that in mind, our task here then will be to employ some 2D image processing to 
  26. supplement 3D applications.
  27.  
  28. Various Seamless Techniques
  29.     There appear to be several methods for creating/converting images into seamless textures. 
  30. We'll focus on a technique that seems best suited for rather homogenous, organic-looking images 
  31. like gases, marble, terrains, rocks and other textures devoid of artificial features. With this method, 
  32. it is important that there be no distinguishing features present in the base texture because they 
  33. will noticeably repeat themselves over the course of multiple tiles, thus destroying the subtle 
  34. effect. However, this rule usually applies to organic textures with no individually recognizable 
  35. elements, unlike bricks, fences, stones, etc. where other methods described below are most likely 
  36. used to create these types of seamless textures. Substances like wood fall on the borderline with 
  37. these methods, depending on how distinct the grain patterns are. Before I describe our quick and 
  38. easy process however, let me briefly mention those other possible techniques.
  39.     One foolproof method for creating seamless images uses a computer algorithm to do the 
  40. work mathematically. Such processes might be found in some of the Photoshop plug-in filter 
  41. technology. No seams, no sweat. Another method suitable for more regular patterned motifs like 
  42. the chain-link fence or brick examples alluded to earlier involves cutting off a strip in just the 
  43. right location from one side, flipping it 180 degrees and enjoining it to the opposite edge in such 
  44. a way so that the pattern repeats naturally. Manual touch-ups with a paint program are usually 
  45. necessary for tweeking the edges together correctly. This method is similar to the one we'll be 
  46. employing.
  47.     Remember, the method we'll be covering is quick and easy, but not entirely foolproof for 
  48. some textures. It is best used to smooth the hard seams for a tiled image. Unlike a true seamless 
  49. image, which are best designed for obvious repeating patterns like bricks or fences, this technique 
  50. produces a quick hack by overlapping the edges with an alpha channel modulating the 
  51. composite process. But, enough with the generalities, here are the specifics.
  52.  
  53. Which Software Will Work?
  54.     Any image processing program that can utilize an Alpha channel for compositing or has a 
  55. transparency gradient mode for brushes will work. This includes programs like The Art 
  56. Department Professional, ImageMaster, OpalPaint, ImageFX and, of course, Photoshop (if you're 
  57. using a Mac emulator). The process described below will use the Alpha channel to composite 
  58. between images, but can easily be adapted to using brushes with an Alpha or transparency 
  59. gradient. Utilizing a brush simply substitutes for cropping a portion of an image and saving that 
  60. piece for later compositing. The following tutorial will describe how to process one edge of an 
  61. image only -- the side. The same technique can then be applied to the top/bottom edge.
  62.  
  63. The How-To Part
  64.     First, scan or digitize some kind of texture, or use an image obtained by some other means 
  65. that isn't already seamless. Load it into your desired image processor. For the record, I'm using 
  66. ADPro. Note and record the image's dimensions W and H. If you have a swap or temporary 
  67. buffer, Save the image to it. This will just make things a little easier when reloading later.
  68.     Next, crop a strip off of the left side of the image that is about 10-20% of the width of the 
  69. entire image but exactly the same height. In other words, this new strip will have dimensions of 
  70. X=W*.1 and Y=H. Save this strip to RAM: or your hard drive as "Strip."
  71.     Now create a strip with the same dimensions (X and Y) as the last strip with a horizontal 
  72. gradient of black to white running from left to right. ADPro's Backdrop loader works quite 
  73. effectively. This image will serve as our Alpha channel mask between the original image and 
  74. Strip. Save this image as "Strip.alpha." Depending on which program you're using, you may need 
  75. to convert this image to 8-bit greyscale for use as an Alpha channel. As of ADPro 2.3 or later, this 
  76. is not necessary when compositing with Alpha images. Refer to Figure 2 if you're having 
  77. problems conceptualizing this process thus far.
  78.     Again, reload the original image, from the swap buffer if applicable, but this time crop the 
  79. area exclusive of the one in which you cropped Strip from. The dimensions should be W'=W-X 
  80. and H'=H, and an X Offset of X. This is our new base image.
  81.     For the final step, with the NewBase image still residing in the work buffer, composite Strip 
  82. onto this image using Strip.alpha as the Alpha channel between the two. Remember to use the 
  83. proper X Offset (W'-X) for both Strip and Strip.alpha so that their right edge aligns with 
  84. NewBase's right edge. The result shows that the image's new right edge gradually fades into its 
  85. old left edge, thus forming a perfect seam with its new left edge. The essential chore is handled 
  86. by the Alpha channel controlling the mix from left to right between NewBase and Strip. Render 
  87. or display your results.
  88.     Don't sweat if you're hard pressed to recognize the difference in its current state. Wrap it 
  89. and the original onto a sphere or cylinder alongside each other in your favorite 3D software and 
  90. then render to better see the difference. You may have to rotate the sphere's heading 90 or 180 
  91. degrees to bring the seams into camera view, depending on where your software positions the 
  92. seam when texture mapping. Check out Figures 3a-3c to see how a scan of Jupiter became 
  93. seamless along the side.
  94.     For complete seamlessness, repeat the process above with this new image, remembering that 
  95. all the previous dimensions will be different and the strip will be across the top, not the side. In 
  96. order to see the results of complete seamlessness once both the top and sides have been 
  97. processed, map (tile) the image onto a plane so that four images fit perfectly across the face like a 
  98. checkerboard (Figure 4c).
  99.  
  100. The Macro
  101.     For those of you using ADPro, I've included yet another ARexx macro that will create a 
  102. seamless image automatically in less time than it takes to blow your nose. Assuming you have 
  103. enough RAM:, a typical image takes approximately 10 seconds. Ahhhh, the power of ARexx!
  104.     First, you'll be prompted to choose whether to process the side, the top or both. Usually, if 
  105. you're only going to be wrapping the image spherically or cylindrically like a planetary or soda 
  106. can texture, creating a seamless side is sufficient. However, if you plan on mapping the texture to 
  107. a plane like a tiled floor, you'll want to do both edges. The "Top Only" choice is included for 
  108. completeness. I haven't yet found a need to tile textures in the vertical direction exclusively.
  109.     Next, you'll be asked to what degree is the texture homogenous in its pattern or motif. As 
  110. mentioned earlier, if the image contains regions of distinct patterns, the strip to be composited 
  111. will have to be cropped larger in order to increase the distance it takes to blend it with the 
  112. underlying region of the base image. In this case, you'd want to select "Chaotic." Otherwise, if you 
  113. can get by with "Homogenous," more of your original texture will remain intact.
  114.     As you can see from the _SeamlessMap.adpro macro, in order to create the Alpha channel 
  115. strip, I've used the BackDrop loader in "Color" mode. Specifying "Grey" fails to use the specified 
  116. color or grey values and direction information properly. I assume this is a bug, but I haven't yet 
  117. contacted Elastic Reality about the matter yet. Anyhow, just specify a color backdrop and use the 
  118. appropriate greyscale values and it'll work fine. If you need to convert the Alpha mask to an 8-bit 
  119. greyscale for earlier versions to composite, add the line:
  120.  
  121.     Operator "Color_To_Grey"
  122.  
  123. right after the BackDrop loader line.
  124.  
  125. Bye
  126.     Well, that about wraps (no pun intended) it up for this time. Hopefully, if you ever need a 
  127. seamless texture in a pinch, you'll keep this quick method in mind -- even quicker with the 
  128. macro. If you despise typing in these macros by hand, feel free to write to me in care of this 
  129. magazine for details on getting this months and any previous macros listed in this column by 
  130. mail or modem. Please allow about 30 days for your letter to reach me from Amazing 
  131. Computing. I'm still wondering why it takes that long myself. Until next time, hope this stuff was 
  132. useful if not mildly interesting. Chow!
  133.